商品历史价格对比查询
'
var goodurl,Historynode;
if(Couponid.method == "taobao"){
if(config.host.indexOf("taobao")!=-1){
goodurl ="https://detail.tmall.com/item.htm?id=" + gid;
}else{
goodurl ="https://"+config.host+"/item.htm?id=" + gid;
}
Historynode = ["#detail",".BasicContent--root--1_NvQmc"];
}else if(Couponid.method == "jd"){
goodurl ="https://item.jd.com/"+ gid+".html";
Historynode =[ ".product-intro"];
}
var addHistory= commonFunction.Commonsetinterval(Historynode);
addHistory.then(function(node){
let b = document.createElement('div');
b.style = "padding:20px;border: 1px solid #eee;margin: 10px auto;position: relative;clear: both;"
b.innerHTML = HistoryHtml;
node.appendChild(b);
ControllerHistory.getHistory(goodurl);
});
},
getHistory:function(goodurl){
let headers ={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Content-Type': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'sec-ch-ua-platform': 'Windows',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Site': 'same-origin',
'Accept-Encoding': 'gzip, deflate, br',
'Sec-Fetch-User': '?1',
'Connection': 'keep-alive',
'Host': 'bijiatool-v2.manmanbuy.com',
}
var request = commonFunction.request("POST","https://bijiatool-v2.manmanbuy.com/ChromeWidgetServices/WidgetServices.ashx?methodName=getBiJiaInfo&jsoncallback=&p_url=" + goodurl,headers);
request.then(function(resdata){
if(resdata.result == "success"){
let obj = JSON.parse(resdata.data);
if(obj.jiagequshi ==undefined||obj.jiagequshiyh ==""){
document.querySelector("#history").innerHTML='
暂未收录
';
}else{
let headhtml ='
历史最低价格 '+obj.lowerPriceyh+'元 数据来源于网络,仅供参考
'
document.querySelector("#historyhead").innerHTML =headhtml;
ControllerHistory.Showchart(obj);
}
}
});
},
Showchart:function(obj){
var strDate = obj.jiagequshiyh;
var chartDom = document.getElementById('container');
var myChart = echarts.init(chartDom);
var option;
var oldData = [];
var data = [];
var currentDay = new Date().setHours(0, 0, 0, 0);
var currentDayDate = new Date(currentDay).getTime();
var minMonth =4,xBlockNum=6;
oldData = eval("([" + strDate + "])");
for (var i = 1; i < oldData.length; i++) {
var key = oldData[i][0];
var j = i - 1;
while (j >= 0 && oldData[j][0] > key) {
oldData[j + 1] = oldData[j];
j--;
}
oldData[j + 1][0] = key;
}
var xInterval, yInterval, yMin, yMax, xMin, xMax, maxValue, minValue, maxDate, minDate, addDate;
addDate = minMonth * 30 * 24 * 60 * 60 * 1000; //日期不足三个月,补到120天
var arrX = [], arrY = [];
console.log(oldData);
for (var l = 0; l < oldData.length;l++) {
if (oldData[l][1] <= 0) continue;
arrX.push(oldData[l][0]);
arrY.push(oldData[l][1]);
data.push([oldData[l][0], oldData[l][1],oldData[l][2]]);
}
console.log(oldData);
if (data.length > 0 && data[data.length - 1][0] < currentDayDate) {
data.push([currentDayDate, data[data.length - 1][1], ""]);
}
maxValue = Math.max.apply(null, arrY); //y轴最大值
minValue = Math.min.apply(null, arrY); //y轴最小值
maxDate = new Date(data[data.length - 1][0]).getTime(); //最大日期
minDate = new Date(data[0][0]).getTime(); //最小日期
yMin = minValue - ((minValue + maxValue) / 2 - minValue); //y轴开始最小值
yMin = yMin >= 0 ? yMin : 0;
yMax = maxValue + (maxValue - minValue) / 4;
if (yMax === yMin) {
yMin = yMin - yMin / 2;
yMax = yMax + yMax / 2;
}
if (maxDate - minDate > addDate) {
xMin = minDate;
} else {
xMin = maxDate - addDate; //往前补四个月
}
xMax = maxDate;
xInterval = (xMax - xMin) / xBlockNum;
yInterval = (yMax - yMin) / xBlockNum;
console.log(arrX );
option = {
animation: false,
tooltip: {
trigger: 'axis',
transitionDuration: 0,
confine: true,
backgroundColor: 'transparent',
padding: 0,
borderWidth: 0,
borderColor: '#ec652e',
position: function (point, params, dom) {
var width = dom.clientWidth;
return [point[0] - width / 2, 0];
},
formatter: function (obj) {
if (obj.length > 0) {
var timeArr = ControllerHistory.getLocalTime(obj[0].data[0]).split('-');
var time = timeArr[0] + '年' + timeArr[1] + '月' + timeArr[2] + '日';
var minPrice = obj[0].data[1];
var youhui = obj[0].data[2];
for (var i = 1; i < obj.length; i++) {
if (obj[i].data[1] < minPrice) {
minPrice = obj[i].data[1];
youhui = obj[i].data[1];
}
}
var retHTML = '
' + time + ' ¥' + minPrice + '
';
if (youhui.length > 0) {
retHTML = '
' + time + ' ¥' + minPrice + " " + youhui + '
';
}
var curDate = new Date();
var vDate = new Date(obj[0].data[0]);
if (obj[0].dataIndex === 0 && vDate > new Date(curDate.getTime() - 24 * 60 * 60 * 1000 * 25 * 30)) {
if (youhui.length > 0) {
retHTML = '
第一次收录 ' + time + ' ¥' + minPrice + " " + youhui + '
';
}
else {
retHTML = '
第一次收录 ' + time + ' ¥' + minPrice + '
';
}
}
return retHTML;
}
},
axisPointer: {
type: 'line',
lineStyle: {
color: '#ec652e'
}
}
},
grid: {
left: "3%",
right: "3%",
bottom: "3%",
top: 20,
containLabel: true
},
xAxis: {
type: 'time',
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#dddddd'
}
},
interval: xInterval,
boundaryGap: false,
align: 'right',
axisLabel: {
align: 'right',
rotate: 0,
color: '#555555',
showMinLabel: true,
showMaxLabel: true,
formatter: function (value, index) {
var date = new Date(value);
//var texts = [(date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1)), date.getDate() > 9 ? date.getDate() : ('0' + date.getDate())];
var texts = [(date.getMonth() + 1), date.getDate()];
if (index === 0) {
texts = [''];
} else if (index === (arrX.length - 1)) {
//texts.unshift(date.getFullYear());
} else {
//texts = [''];
}
return texts.join('-');
}
},
splitLine: {
show: true,
lineStyle: {
color: ['#ddd'],
type: 'solid',
opacity: .8
}
},
min: function (value) {
return xMin;
},
max: function (value) {
return xMax;
}
},
yAxis: {
type: 'value',
axisTick: {
show: false
},
interval: yInterval,
boundaryGap: false,
scale: true,
axisLabel: {
show: true,
inside: false,
showMinLabel: true,
showMaxLabel: true,
color: '#555',
formatter: function (value, index) {
if (index === 0) {
} else {
return value.toFixed(0);
}
}
},
axisLine: {
lineStyle: {
color: '#dddddd'
}
},
splitLine: {
show: true,
lineStyle: {
color: ['#ddd'],
type: 'solid',
opacity: .8
}
},
//最小刻度
min: function (value) {
return yMin;
},
max: function (value) {
return yMax;
}
},
series: [{
name: '价格',
type: 'line',
symbol: 'circle',
symbolSize: [2, 2],
showSymbol: false,
itemStyle: {
color: '#ff6729'
},
lineStyle: {
width: 2,
shadowColor: '#dddddd',
shadowBlur: 0,
shadowOffsetY: 0.3,
shadowOffsetX: 0,
z: 22
},
markLine: {
silent: true,
symbol: 'none',
data: [{
type: 'max',
symbol: 'none',
lineStyle: {
color: '#888888',
type: 'dotted',
width: 0.8
},
label: {
position: 'end',
formatter: '{c}',
color: 'transparent'
//color: '#555555'
}
}, {
type: 'min',
symbol: 'none',
lineStyle: {
color: '#888888',
type: 'dotted',
width: 0.8
},
label: {
position: 'end',
formatter: '{c}',
color: '#555555'
}
}],
label: {
show: true,
position: 'left'
}
},
data: data
}],
};
if (maxDate - minDate < addDate) {
var lineDash = [{
coord: [xMin, arrY[0]],
lineStyle: {
width: 1.3
}
}, {
coord: [arrX[0], arrY[0]]
}];
option.series[0].markLine.data.push(lineDash)
}
myChart.clear();
myChart.setOption(option, true);
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 1,
dataIndex: 1
})
},
getLocalTime:function(nS) {
var year = new Date(parseInt(nS)).getFullYear();
var mouth = new Date(parseInt(nS)).getMonth() + 1;
mouth = mouth < 10 ? '' + mouth : mouth;
var day = new Date(parseInt(nS)).getDate() < 10 ? '' + new Date(parseInt(nS)).getDate() : new Date(parseInt(nS)).getDate();
return year + '-' + mouth + '-' + day;
},
}
//历史价格查询结束
//短视频下载开始
const ControllerShortvideo ={
ShortvideoidList:function(){
var ShortvideoidList = [
{ url:"www.douyin.com", videoid:commonFunction.geturlid(config.playhref),nodeid:[".xg-right-grid"]},
{ url:"www.kuaishou.com", videoid:commonFunction.geturlid(config.playhref),nodeid:[".right"]},
{ url:"www.ixigua.com", videoid:commonFunction.geturlid(config.playhref),nodeid:[".xg-right-grid"]},
];
var Shortvideoid = {};
for(var i in ShortvideoidList) { //获得窗口ID
if (ShortvideoidList[i].url == config.host) {
Shortvideoid = {
videoid :ShortvideoidList[i].videoid,
nodeid :ShortvideoidList[i].nodeid
}
return Shortvideoid
break;
}
}
if(!Shortvideoid){
return;
}
},
ToastDwon:function(videourl,filename,mode) {
var m = document.createElement('div');
m.innerHTML ='
下载视频 ';
m.setAttribute('id','dwon');
m.style.cssText = "max-width: 480px;min-width: 150px;padding: 0 25px;height: 200px;color: #323442;line-height: 20px;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999998;background: #fff;font-size: 16px;box-shadow: 1px 1px 50px rgb(0 0 0 / 40%);font-family: PingFang SC, HarmonyOS_Regular, Helvetica Neue, Microsoft YaHei, sans-serif;";
document.body.appendChild(m);
document.querySelector("#close").addEventListener('click',function() {
document.body.removeChild(document.querySelector("#dwon"))
})
document.querySelector("#videofile").addEventListener('click',function() {
commonFunction.Toast("创建下载需要时间,长时间未创建,点击浏览器打开,右键另存为",4000);
if(mode ==1){
GM_download({
url:videourl+'.mp4',
name: filename,
saveAs: true, //布尔值,显示"保存为"对话框
onerror: function (error) {
commonFunction.Toast("下载出错,点击浏览器打开手动保存",3000)
},
onprogress: (pro) => {
},
ontimeout: () => {
//如果此下载由于超时而失败,则要执行的回调
commonFunction.Toast("下载超时,点击浏览器打开手动保存",3000)
},
onload: () => {
commonFunction.Toast(filename+"下载完成",3000)
}
})
}else{
fetch(videourl+'.mp4').then(res => res.blob()).then(blob => {
const a = document.createElement('a');
document.body.appendChild(a)
a.style.display = 'none'
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
document.body.removeChild(a)
window.URL.revokeObjectURL(url);
});
}
})
},//公共下载弹窗结束
//抖音下载开始
douyinbtn:function() {
var Shortvideoid = ControllerShortvideo.ShortvideoidList();
let downhtml = '
';
var douyin= commonFunction.Commonsetinterval(Shortvideoid.nodeid);
douyin.then(function(node){
var b = document.createElement('xg-icon');b.innerHTML = downhtml;
b.setAttribute("class","xgplayer-autoplay-setting automatic-continuous");
b.setAttribute("id","downvideo");
node.appendChild(b);
ControllerShortvideo.getdouyinvideo(Shortvideoid.videoid);
});
},
getdouyinvideo:function(d){
document.querySelector('#downvideo').addEventListener('click',function() {
commonFunction.Toast("正在获取视频文件",3000)
if (d != "") {
var request = commonFunction.request("GET","https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=" + d,null,null);
request.then(function(resdata){
if(resdata.result == "success"){
var json=JSON.parse(resdata.data);
console.log(json)
if(json.status_code==0){
let vid = json.item_list[0].video.vid;
if(vid){
var filename = d+".mp4";
var url = "https://aweme.snssdk.com/aweme/v1/play/?video_id="+vid+"&ratio=1080p&line=0";
commonFunction.Toast("视频获取成功",3000)
ControllerShortvideo.ToastDwon(url,filename,1);
}else{
commonFunction.Toast("视频文件获取失败",3000)
}
}
}
});
} else {
console.log('视频id为空!');
}
});
},//抖音下载结束
//快手下载开始
kuaishoubtn:function() {
var Shortvideoid = ControllerShortvideo.ShortvideoidList();
var kuaishou= commonFunction.Commonsetinterval(Shortvideoid.nodeid);
kuaishou.then(function(node){
var b = document.createElement('div');
b.innerHTML = '
下载
';
b.setAttribute("class","kwai-player-volume-container player-bar-volume show-volume-slide");
b.setAttribute("data-v-0c78ed39","");
b.setAttribute("data-v-5037d859","");
b.setAttribute("data-v-2475c26c","");
b.setAttribute("data-v-56544f8e","");
b.setAttribute("id","downvideo");
node.insertBefore(b,node.childNodes[0]);
if(config.playhref.indexOf("short-video")!=-1){
var e = document.querySelector(".total")
e.style.right ="180px"
var f = document.querySelector(".player-bar-progress")
f.style.width ="calc(100% - 318px)";
}
ControllerShortvideo.getksvideo(Shortvideoid.videoid)
});
},
getksvideo:function(d){
document.querySelector('#downvideo').addEventListener('click',function() {
commonFunction.Toast("正在获取视频文件",1000)
let videonode = document.querySelector("video")
let src =videonode.getAttribute("src")
let pausebtn = document.querySelector(".pause-icon");
if(pausebtn != null){
pausebtn.click();
}
if(src.indexOf("blob:") != -1){
let params ='{"operationName":"visionVideoDetail","variables":{"photoId":"'+d+'","page":"detail"},"query":"query visionVideoDetail($photoId: String, $type: String, $page: String, $webPageArea: String) {\\n visionVideoDetail(photoId: $photoId, type: $type, page: $page, webPageArea: $webPageArea) {\\n status\\n type\\n author {\\n id\\n name\\n following\\n headerUrl\\n __typename\\n }\\n photo {\\n id\\n duration\\n caption\\n likeCount\\n realLikeCount\\n coverUrl\\n photoUrl\\n liked\\n timestamp\\n expTag\\n llsid\\n viewCount\\n videoRatio\\n stereoType\\n croppedPhotoUrl\\n manifest {\\n mediaType\\n businessType\\n version\\n adaptationSet {\\n id\\n duration\\n representation {\\n id\\n defaultSelect\\n backupUrl\\n codecs\\n url\\n height\\n width\\n avgBitrate\\n maxBitrate\\n m3u8Slice\\n qualityType\\n qualityLabel\\n frameRate\\n featureP2sp\\n hidden\\n disableAdaptive\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n tags {\\n type\\n name\\n __typename\\n }\\n commentLimit {\\n canAddComment\\n __typename\\n }\\n llsid\\n danmakuSwitch\\n __typename\\n }\\n}\\n"}';
let headers = {
"Content-type": "application/json"
};
var request = commonFunction.request("POST","https://www.kuaishou.com/graphql",headers,params);
request.then(function(resdata){
if(resdata.result == "success"){
let obj=JSON.parse(resdata.data);
let src=obj.data.visionVideoDetail.photo.photoUrl;
commonFunction.Toast("视频获取成功",1000)
ControllerShortvideo.ToastDwon(src,d,"")
}
})
}else{
commonFunction.Toast("视频获取成功",1000)
ControllerShortvideo.ToastDwon(src,d,"")
}
})
},
//快手下载结束
//西瓜视频下载开始
xiguabtn:function() {
setTimeout(function(){
var Shortvideoid = ControllerShortvideo.ShortvideoidList();
var xigua= document.querySelector(Shortvideoid.nodeid[0]);
console.log(xigua)
if(xigua){
let btnHTML = '
';
xigua.insertAdjacentHTML('afterbegin', btnHTML);
ControllerShortvideo.getxgvideo(Shortvideoid.videoid)
};
},3000);
},
getxgvideo:function(d){
document.querySelector('#downvideo').addEventListener('click',function() {
commonFunction.Toast("正在获取视频文件",1000);
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("POST","http://47.99.158.118/video-crack/v2/parse?content="+config.playhref,headers,null);
request.then(function(resdata){
if(resdata.result == "success"){
let obj=JSON.parse(resdata.data);
if(obj.code == 0){
commonFunction.Toast("视频获取成功",1000)
ControllerShortvideo.ToastDwon(obj.data.url,d)
}else {
commonFunction.Toast("此视频不支持解析")
}
}
})
})
}
//西瓜视频下载结束
}
//短视频下载结束
//aria2设置开始
const Controlleraria2 = {
aria2set:function(b){
let css= `
.layui-form{display: flex;margin-top: 20px;}
.layui-form-label{box-sizing: content-box;}
.layui-input-block p{font-size:12px}
.layui-form-item{margin-bottom:5px}
.layui-input-block{min-height:auto;}
.main-left{width: 367px;}
.zhihu-scan{width:180px;display:inline-block;text-align: center;margin-right: 40px;}
.zhihu-scan img{width: 140px;margin: 0 5px 10px 5px;}
.zhihu-scan h1{font-size: 18px;font-weight: bold;margin: 0px 0 20px 0;}
.zhihu-scan p{margin: 0;color: #666;font-size: 14px;}
`;
commonFunction.GMaddStyle(css);
document.querySelector("#aria2set") .addEventListener('click',function() {
let rpc="ws://localhost:6800/jsonrpc";
if(commonFunction.getItem("rpc")!=null){
rpc= commonFunction.getItem("rpc")
}
let token="";
if(commonFunction.getItem("token")!=null){
token= commonFunction.getItem("token")
}
let mulu="D:/";
if(commonFunction.getItem("mulu")!=null&&commonFunction.getItem("mulu")!=""){
mulu= commonFunction.getItem("mulu")
}
let plcode="";
if(commonFunction.getItem("plcode")!=null){
plcode= commonFunction.getItem("plcode")
}
let contenthtml ="";
contenthtml +='
'
commonFunction.open({
area: ['580', '450'],
title: "批量下载设置",
shade: 0,
id:"biliset",
btn: ['取消', '保存设置'],
content:contenthtml,
btn1: function(data) {
var n = data.getElementsByTagName('input');
for(let i= 0; i
{
console.log(event);
commonFunction.Toast('连接错误, Aria2 连接错误,请检查RPC设置!');
};
ws.onopen = () => { ws.send(JSON.stringify(json)); }
ws.onmessage = event => {
let received_msg = JSON.parse(event.data);
console.log(received_msg);
if (received_msg.error !== undefined) {
if (received_msg.error.code === 1)commonFunction.Toast('通过RPC连接失败', '请打开控制台查看详细错误信息,返回信息:' + received_msg.error.message);
}
resolve();
switch (received_msg.method) {
case "aria2.onDownloadStart":
commonFunction.Toast("Aria2 发送成功, "+filename+" 已经开始下载!",1000);
ws.close();
break;
default:
break;
}
};
});
},
plaria2:function(i,arr){
setTimeout(function(){
if(++i < arr.length){
Controlleraria2.addUri(arr[i].url,arr[i].title)
Controlleraria2.plaria2(i,arr);
console.log(i,arr.length)
}
}, Math.random() * 1000);
}
};
//aria2设置结束
//Bilibili下载开始
const ControllerBilibili ={
Addlist:async function(){
const listHtml = ()=>{
var Bilihtml="";
var episodes = ZHwindow?.__INITIAL_STATE__?.sections[0]?.episodes;
if(!episodes){
let aid = ZHwindow?.__INITIAL_STATE__?.videoData?.aid;
if(!aid)return;
let videolist = ZHwindow?.__INITIAL_STATE__?.videoData?.pages;
for (let i = 0; i < videolist.length; i++) {
Bilihtml += ' ';
}
}else {
for (let i = 0; i < episodes.length; i++) {
Bilihtml += ' ';
}
}
return Bilihtml;
}
var AddBi= commonFunction.Commonsetinterval(["#danmukuBox"]);
AddBi.then(async function(node){
await commonFunction.sleep(3000);
let Bilihtml = await listHtml();
if(!Bilihtml){commonFunction.Toast("获取下载列表失败,刷新重试");return;}
let dataV = node.attributes[2]?.name??"data-v";
let downhtml = '';
node.insertAdjacentHTML('afterEnd', downhtml);
ControllerBilibili.bilibilidown();
});
},
bilibilidown:function(){
var inu = document.querySelector("#downBox");
var b=inu.getElementsByTagName('input');
Controlleraria2.aria2set(b);
document.querySelector("#sanlian") .addEventListener('click',function() {
console.log("一键三连");
document.querySelector(".like").click();
document.querySelector(".coin").click();
});
document.querySelector("#pldown") .addEventListener('click',function() {
let passwordCode = commonFunction.getItem("plcode");
if (passwordCode !=""&&passwordCode !=null) {
let headers = {
"Content-Type": "text/html; charset=utf-8"
};
let request = commonFunction.request("GET","http://tool.zhihupe.com/bdwpcs.php?m=BILIBILI&author="+author+"&PWD="+passwordCode,headers,null);
request.then(function(resdata){
let json=JSON.parse(resdata.data);
if(json.error == 1){
let arr =[];
b.forEach(function(element) {
if(element.checked == true){
let aid = element.getAttribute("data-aid");
let cid = element.getAttribute("data-cid");
let title = element.getAttribute("title");
let json ={
"aid": aid,
"cid": cid,
"title": title,
};
arr.push(json);
}
})
if(arr.length == 0){
commonFunction.Toast("请选择需要下载的视频",3000)
}else{
ControllerBilibili.bipldown(arr);
}
}else if(json.error == -2){
let msg =json.msg
commonFunction.Toast(msg);
}else {
commonFunction.Toast('服务器请求失败,请重试!');
}
})
}else {
commonFunction.Toast('请在脚本设置里输入验证码!');
}
});
let biliList = document.getElementsByClassName('bilidown');
console.log(biliList);
for (var i = 0; i < biliList.length; i++) {
biliList[i].addEventListener('click',function() {
let aid = this.getAttribute("data-aid");
let cid = this.getAttribute("data-cid");
let title = this.getAttribute("title");
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("GET","https://api.bilibili.com/x/player/playurl?avid="+aid+"&cid="+cid+"&qn=112",headers,null);
request.then(function(resdata){
let obj=JSON.parse(resdata.data);
if(obj.code == 0){
window.open(obj.data.durl[0].url,false);
console.log(obj)
}else{
commonFunction.Toast("获取下载链接失败");
}
})
});
}
},
//批量下载相关代码
bipldown:function(a){
let pldownarr=[];
for (var i = 0; i < a.length; i++) {
let title = i+1+"、"+a[i].title;
title =title.replace(/[\ |\~|\`|\=|\||\\|\;|\:|\"|\'|\,|\.|\>|\/]/g,"_");
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("GET","https://api.bilibili.com/x/player/playurl?avid="+a[i].aid+"&cid="+a[i].cid+"&qn=112",headers,null);
request.then(function(resdata){
let obj=JSON.parse(resdata.data);
if(obj.code == 0){
let json ={
"url": obj.data.durl[0].url,
"title":title+".flv",
};
pldownarr.push(json);
if(pldownarr.length==a.length){
console.log(pldownarr);
Controlleraria2.plaria2(-1,pldownarr);
}
}else{
commonFunction.Toast("获取下载链接失败");
}
})
}
},
};
//Bilibili下载结束
//喜马拉雅下载开始
const Controllerximalaya = {
addximalaya:async function(){
// await commonFunction.sleep(3000);
if(config.playhref.indexOf("www.ximalaya.com/album")!= -1){
let albumId = commonFunction.geturlid(config.playhref);
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("GET","https://www.ximalaya.com/revision/album/v1/getTracksList?albumId="+albumId+"&pageNum=1",headers,null);
request.then(function(resdata){
let obj=JSON.parse(resdata.data);
if(obj.ret == 200){
let trackTotalCount =obj.data.trackTotalCount;
if(trackTotalCount<=100){
var page = 1
}else{
page =Math.ceil(trackTotalCount/100)
}
let arr1 =[];
return new Promise(function(resolve, reject){
recurTest(0, page,albumId,arr1);
function recurTest(j,length,albumId,arr){
setTimeout(function(){
if(++j <= length){
let headers = {
"Content-type": "application/json"
};
let request2 = commonFunction.request("GET","https://www.ximalaya.com/revision/album/v1/getTracksList?albumId="+albumId+"&pageSize=100&pageNum="+j+"&sort=0",headers,null);
request2.then(function(resdata2){
let obj=JSON.parse(resdata2.data);
if(obj.ret == 200){
let tracks =obj.data.tracks;
arr1 = arr.concat(tracks)
console.log(arr1)
recurTest(j, length,albumId,arr1);
if(j==length){
resolve(arr1)
};
}else{
commonFunction.Toast("获取下载列表失败");
}
});
console.log(j, length,albumId)
}
}, Math.random() * 100);
}
}).then((listarr) => {
let downhtml=""
for (var i = 0; i < listarr.length; i++) {
downhtml += ''+listarr[i].index+'.'+listarr[i].title+'
';
}
var xm= commonFunction.Commonsetinterval([".xui-card"]);
xm.then(function(node){
let listHTML ='';
node.insertAdjacentHTML('afterEnd',listHTML);
Controllerximalaya.ximalayadown();
});
})
}
});
}else{
let list = document.getElementsByClassName('album-cover');
if(list!=null){
for (var i in list) {
list[i].addEventListener('click',function() {
let url =this.getAttribute("href");
const a = document.createElement('a');
document.body.appendChild(a)
a.style.display = 'none'
a.href = url;
a.target="_blank"
a.click();
window.location.reload();
})
}
}
}
},
ximalayadown:function(){
var inu = document.querySelector("#downBox");
var b=inu.querySelectorAll('input');
Controlleraria2.aria2set(b);
document.querySelector("#pldown").addEventListener('click',function() {
let passwordCode = commonFunction.getItem("plcode");
if (passwordCode !=""&&passwordCode !=null) {
let headers = {
"Content-Type": "text/html; charset=utf-8"
};
let request = commonFunction.request("GET","http://tool.zhihupe.com/bdwpcs.php?m=BILIBILI&author="+author+"&PWD="+passwordCode,headers,null);
request.then(function(resdata){
var json=JSON.parse(resdata.data);
if(json.error == 1){
let arr =[];
b.forEach(function(element) {
if(element.checked == true){
let trackId = element.getAttribute("data-trackId");
let title = element.getAttribute("title");
let json ={
"trackId": trackId,
"title": title,
};
arr.push(json);
}
})
if(arr.length == 0){
commonFunction.Toast("请选择需要下载的音频",3000)
}else{
console.log(arr)
Controllerximalaya.ximapldown(arr);
}
}else if(json.error == -2){
let msg =json.msg
commonFunction.Toast(msg);
}else {
commonFunction.Toast('服务器请求失败,请重试!');
}
});
}else {
commonFunction.Toast('请在脚本设置里输入验证码!');
}
});
let ximaList = document.getElementsByClassName('ximadown');
console.log(ximaList);
for (var i = 0; i < ximaList.length; i++) {
ximaList[i].addEventListener('click',function() {
let trackId = this.getAttribute("data-trackId");
let title = this.getAttribute("title");
commonFunction.Toast('正在获取下载链接')
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("GET",'https://mobile.ximalaya.com/mobile-playpage/track/v3/baseInfo/'+new Date().getTime()+'?device=web&trackId='+trackId,headers,null);
request.then(function(resdata){
let obj = JSON.parse(resdata.data);
console.log(obj)
if(obj.ret == 0){
let playUrlList = obj.trackInfo?.playUrlList??"";
if(playUrlList ==""){commonFunction.Toast('链接获取失败,普通用户无法获取部分VIP音频');return}
let downUrl =playUrlList[0]?.url;
let str1 = downUrl.replaceAll('-','+');
let str2 = str1.replaceAll('_','/');
let num = str2.length%4;
if(num){
str2 += '===='.substr(num);
}
let url = CryptoJS.AES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(str2)
}, CryptoJS.enc.Hex.parse("aaad3e4fd540b0f79dca95606e72bf93"), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}).toString(CryptoJS.enc.Utf8);
console.log(url);
if(url){
GM_download(url,obj.trackInfo.title+'.mp3');
}else{
commonFunction.Toast('解密地址失败');
}
}else{
commonFunction.Toast("获取下载链接失败");
}
});
});
}
},
ximapldown:function(arr){
let pldownarr =[]
for (var i = 0; i < arr.length; i++) {
let title = i+1+"、"+arr[i].title;
title =title.replace(/[\ |\~|\`|\=|\||\\|\;|\:|\"|\'|\,|\.|\>|\/]/g,"_")+".m4a";
let headers = {
"Content-type": "application/json"
};
let request = commonFunction.request("GET",'https://mobile.ximalaya.com/mobile-playpage/track/v3/baseInfo/'+new Date().getTime()+'?device=web&trackId='+arr[i].trackId,headers,null);
request.then(function(resdata){
let obj = JSON.parse(resdata.data);
console.log(obj)
if(obj.ret == 0){
let playUrlList = obj.trackInfo?.playUrlList??"";
if(playUrlList ==""){commonFunction.Toast('链接获取失败,普通用户无法获取部分VIP音频');return}
let downUrl =playUrlList[0]?.url;
let str1 = downUrl.replaceAll('-','+');
let str2 = str1.replaceAll('_','/');
let num = str2.length%4;
if(num){
str2 += '===='.substr(num);
}
let url = CryptoJS.AES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(str2)
}, CryptoJS.enc.Hex.parse("aaad3e4fd540b0f79dca95606e72bf93"), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}).toString(CryptoJS.enc.Utf8);
console.log(url);
url
if(url){
// addUri(decrypted,title)
let json ={
"url": url,
"title": title,
};
pldownarr.push(json)
if(pldownarr.length==arr.length){
console.log(pldownarr);
Controlleraria2.plaria2(-1,pldownarr);
}
}else{
commonFunction.Toast('解密地址失败');
}
}else{
commonFunction.Toast("获取下载链接失败");
}
});
}
},
}
//喜马拉雅下载结束
//-----------------------------------------------------------------------
//教育盘论坛开始
const Controllerforum = {
jiaoyupan:function(){
var jiaoyupannode= commonFunction.Commonsetinterval([".copy_pswd"]);
jiaoyupannode.then(function(node){
let v = node.getAttribute("onclick");
let data = v.split(",");
let aid = data[0].split("'")[1];
let formhash = data[1].split("'")[1];
let href = window.location.origin + "/plugin.php?id=threed_attach:downld&aid=" + aid + "&formhash=" + formhash;
console.log(href)
let btnhtml='';
document.body.insertAdjacentHTML('afterEnd',btnhtml);
});
}
}
//教育盘论坛结束
//------------------------------------------------------------------------
//文库下载开始
const Controllerdocs = {
jsPDF: function(){
if (unsafeWindow.jspdf) return unsafeWindow.jspdf;
commonFunction.GMaddScript('https://cdn.staticfile.org/jspdf/2.5.1/jspdf.umd.min.js');
return unsafeWindow.jspdf;
},
addStatus:function(){
const statusOverlay = ``;
const messageOverlay = ``;
document.body.insertAdjacentHTML('afterbegin', statusOverlay);
document.body.insertAdjacentHTML('afterbegin', messageOverlay);
document.head.appendChild(document.createElement('style')).innerHTML = `
.s-top{position: fixed;top: 0;left: 0;bottom: 0;right: 0;z-index: 99999999;padding-top: 40vh;display: none;}
.s-top.s-top-message{text-align: center;}
.s-message{background-color: #000000aa;color: white;padding: 8px 14px;text-align: center;font-size: 18px;border-radius: 6px;display: inline-block;}
.s-top.s-top-status{z-index: 99999998;cursor: wait;background-color: rgba(0, 0, 0, 0.4);backdrop-filter: blur(10px) saturate(1.8);}
.s-top.show{display: block;}
.s-panel{background: white;width: 90%;max-width: 480px;border-radius: 12px;padding: 14px 24px;margin: 0 auto;}
.s-progress-wrapper{height: 24px;border-radius: 12px;width: 100%;background-color: #eeeff3;overflow: hidden;margin-bottom: 12px;}
.s-progress{background-color: #54be99;height: 24px;width: 0;transition: width 0.2s ease;}
.s-status{display: flex;font-size: 14px;}
.s-text{flex-grow: 1;color: #5f5f5f;}
.s-progress-text{color: #54be99;font-weight: bold;}
.s-message{}
.swal2-actions{margin: 20px auto 0;}
.swal2-styled.swal2-cancel{border-radius: 5px;font-size: 16px;}
.swal2-styled.swal2-confirm{border-radius: 5px;font-size: 16px;}
.swal2-styled{margin: 5px;padding: 8px 16px;}
.none{display:none}
`;
},
showStatus:function(text='', progress=-1){
document.querySelector('.s-top.s-top-status').classList.add('show');
if(text) document.querySelector('.s-panel .s-text').innerHTML = text;
if (progress >= 0) {
progress = Math.min(progress, 100);
document.querySelector('.s-panel .s-progress').style.width = `${Math.floor(progress)}%`;
document.querySelector('.s-panel .s-progress-text').innerHTML = `${Math.floor(progress)}%`;
}
},
hideStatus:function(){
document.querySelector('.s-top.s-top-status').classList.remove('show');
},
imgtocanvas:async function (doc,pageSize,img){
const canvas = document.createElement('canvas');
const [w, h] = [canvas.width, canvas.height] = [pageSize[0],pageSize[1]];
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0,0);
doc.addImage(canvas, 'PNG',0, 0, w, h);
canvas.remove();
},
yuanchuangliPPT:async function(){
await Controllerdocs.addStatus();
const loadScript = url => new Promise((resolve, reject) => {
const removeWrap = (func, ...args) => {
if (script.parentNode) script.parentNode.removeChild(script);
return func(...args)
}
const script = document.createElement('script');
script.src = url;
script.onload = removeWrap.bind(null, resolve);
script.onerror = removeWrap.bind(null, reject);
document.head.appendChild(script);
})
const loadJsPDF = async () => {
if (unsafeWindow.jspdf) return unsafeWindow.jspdf;
await loadScript('https://cdn.staticfile.org/jspdf/2.5.1/jspdf.umd.min.js');
return unsafeWindow.jspdf;
}
const htmltocanvas = (view,w,h)=>new Promise(async (resolve, reject) => {
html2canvas(view).then((canvas)=> {
resolve(canvas);
console.log(canvas)
});
})
const downloadPDF = async ()=>{
const jspdf = await loadJsPDF();
await commonFunction.GMaddScript("https://cdn.staticfile.org/html2canvas/1.4.1/html2canvas.min.js");
let PageCount = Page_Count();
let doc;
let docview = document.querySelector(`#view0`);
var w = parseInt(docview.clientWidth);
var h = parseInt(docview.clientHeight);
var pageSize =[w,h]
Controllerdocs.showStatus('正在加载', 0);
for(let i = 0;i{
let currentpage = document.querySelector("#PageIndex").innerText;
currentpage = parseInt(currentpage);
return currentpage;
}
const Page_Count = ()=>{
let PageCount = document.querySelector("#PageCount").innerText;
PageCount = parseInt(PageCount);
return PageCount;
}
const pagenum = ()=>{
let currentpage = current_page();
let PageCount = Page_Count();
if(currentpage{
for(let i = 0;i开始下载
`;
document.body.insertAdjacentHTML('afterbegin', btnhtml);
document.querySelector("#jxdown").onclick = ()=>{
pagenum();
}
},
yuanchuangli:async function(){
await Controllerdocs.addStatus();
const imgLoad = (url) => {
var img = new Image();
img.src = url;
if (img.complete) {
return [img.width, img.height];
} else {
img.onload = function () {
return [img.width, img.height];
img.onload = null;
};
};
};
const loadImage = (url) => new Promise(async (resolve, reject) => {
if (!url) {
resolve(null);
return;
}
let img = await request('GET', url, null, 'blob');
let imgEl = document.createElement('img');
imgEl.onload = () => {
resolve(imgEl);
}
imgEl.onabort = imgEl.onerror = reject;
imgEl.src = URL.createObjectURL(img);
})
const request = (method, url, data, responseType = 'text') => new Promise((resolve, reject) => {
GM.xmlHttpRequest({
method,
url,
data,
responseType,
onerror: reject,
ontimeout: reject,
onload: (response) => {
if (response.status >= 200 && response.status < 300) {
resolve(responseType === 'text' ? response.responseText : response.response);
} else {
reject(new Error(response.statusText));
}
}
});
});
const loadScript = url => new Promise((resolve, reject) => {
const removeWrap = (func, ...args) => {
if (script.parentNode) script.parentNode.removeChild(script);
return func(...args)
}
const script = document.createElement('script');
script.src = url;
script.onload = removeWrap.bind(null, resolve);
script.onerror = removeWrap.bind(null, reject);
document.head.appendChild(script);
})
const loadJsPDF = async () => {
if (unsafeWindow.jspdf) return unsafeWindow.jspdf;
await loadScript('https://cdn.staticfile.org/jspdf/2.5.1/jspdf.umd.min.js');
return unsafeWindow.jspdf;
}
const downloadPDF = async (WebPreview)=>{
let titleText = unsafeWindow?.base.detail.title;
let title;
if(titleText){
title = titleText.split(".")[0]
}else{
title = "原创力文档"
}
Controllerdocs.showStatus('正在加载', 0);
const jspdf = await loadJsPDF();
let doc;
let previewImages = WebPreview.Data.images;
const img = imgLoad(previewImages[1].src);
let startnum = unsafeWindow.fenpi.startnum;
let endnum = unsafeWindow.fenpi.endnum;
for(let i = startnum;i <= endnum; i++){
Controllerdocs.showStatus('正在准备', ((i + 1) / previewImages.length) * 100);
const pageSize =[img[0],img[1]];
console.log(img[1])
if (!doc) {
doc = new jspdf.jsPDF({
orientation: pageSize[0] < pageSize[1] ? 'p' : 'l',
unit: 'pt',
format: pageSize,
compress: true
});
} else {
doc.addPage(pageSize);
}
Controllerdocs.showStatus('正在下载图片');
const previewImg = await loadImage(previewImages[i].src);
await Controllerdocs.imgtocanvas(doc,pageSize,previewImg);
Controllerdocs.showStatus('正在绘制');
if(previewImg?.src) URL.revokeObjectURL(previewImg.src);
previewImg.remove();
}
doc.save(`${title}.pdf`);
Controllerdocs.hideStatus();
}
const checkPreview = (WebPreview) =>{
let previewImages = WebPreview.Data.images;
let arr =[];
for(let i = 1;i < previewImages.length; i++){
if(previewImages[i].status == "init") arr.push(i);
}
return arr;
}
const Previewresult = (WebPreview)=>{
let Previewfalse = checkPreview(WebPreview);
var toasttext = "";
if(Previewfalse != ""){
for ( let key in Previewfalse){
toasttext += "第"+Previewfalse[key]+"页;";
document.querySelector("#jxdown").style.display = "block";
document.querySelector("#downbox").style.display = "none";
}
commonFunction.Toast(toasttext+"预览失败,请手动预览上述页码",5000);
}else{
downloadPDF(WebPreview);
}
}
const exportPDF = async(event,startnum,endnum,yulannum)=>{
let WebPreview = unsafeWindow?.WebPreview;
let previewmain =document.querySelector('.preview');
if(yulannum == "") yulannum = 100;
unsafeWindow.fenpi ={
startnum:1,
endnum:WebPreview.Data.preview_page
}
try {
if(!WebPreview){
commonFunction.Toast("文档下载失败,刷新页面重试一次",3000);
return
}
if(previewmain){
previewmain.style.display = "block"
}else{
commonFunction.Toast("预览失败",3000);
return
}
if(startnum!=""&&endnum!=""){
if(parseInt(startnum)